
import {
	apiGetYwType,
	apiSearchYwType,
	apiSearchName,
	apiServerRegister,
	apiServerRegisterGetFabuArea,
	apiServerRegisterGetFabuAreaCollect,
	apiGetYuanData2Type,
	apiGetFTPData,
	apiPushDetail,
	apiSearchServer,
	apiGetServerList,
	apiDealForm,
	apiDealFormUpdata,
	apiCollectFormPush,
	apiDictionarySearchById,
	apiShareDetail,
	apiGetCollectDetail,
	apiGetShareCollectList,
	apiCollectFormUpdata,
	apiServerRegisterFormUpdata,
	apiCollectAll,
	apiGroupDetail,
	apiAddYuanData,
	apiConnDataAdd,
	apiCheckName,
	apiGetTable,
	apiGetValue,
	apiCollectListRun,
	apiCollectListStop,
	apiGentableSql,
} from './serverResourceApi';

function findKey (obj,value, compare = (a, b) => a === b) {/*根据对象值找到Key*/
  return Object.keys(obj).find(k => compare(obj[k], value))
}

function findIndex(a,obj) { var i = a.length; while (i--) { if (a[i] === obj) { return i; } } return false; }/*根据数组值找索引*/

export const findIndexExport=(a,obj)=>{
	 var i = a.length; 
	 while (i--){
	 	if (a[i].chineseName === obj)
	 		{ return i; }
	 	} 
	 	return false;
}

export const componentGetYwType = (ev,param) => {/*获取业务类型，网段区域，信息类型*/
 				apiGetYwType(param).then((res)=>{
 					if(res.data.code==='S100101'){
 						let searchList = res.data.data.list;
 						for(let i in searchList){
 							switch (searchList[i].type){
 								case 'business_type':
 								ev.treeSeach.business_type = searchList[i].childList;
 								break;
 								case 'info_type':
 								ev.treeSeach.info_type = searchList[i].childList;
 								break;
 							
 								default:
 								break;
 							}
 						}
 						if(ev.formLabel.length!=0){
							ev.formLabel[1].options=ev.treeSeach.business_type;
							ev.formLabel[1].options.unshift({id: "9527",name:"选择全部"});
							console.log(ev.formLabel[1].options);
 						}
 						
 					}
 				})
};

export const componentCollectAll = (ev) =>{/*新的获取网段*/
	apiCollectAll().then((res)=>{
		ev.treeSeach.segment = res.data.data
	})
}

function getTreeName(ev,name,id){
	let tree =  ev.treeSeach[name].map((item)=>{
		if(item.id == id){
			return item;
		}
	})
	return tree;
}

export const componentSearchYwType = (ev,param) => {/*搜索业务类型，网段区域，信息类型*/
	console.log(param.businessTypeIds);
	let businessId = typeof(param.businessTypeIds)==='undefined'?null:[param.businessTypeIds]
	if(param.businessTypeIds==="9527"){
		businessId = [];
	}
	ev.loading=true;
 	apiSearchYwType({
 		'businessTypeIds': businessId,
 		'serviceType':1,
 		'name':param.name||'',
 		"pageNum": param.pageNum,
        "pageSize": 10
 	}).then((res)=>{
 		console.log(res);
 		ev.total = res.data.data.total;
 		let searchList = res.data.data.list;
 		ev.tableData = [];
 		for (let i in searchList){
 			ev.tableData.push({
 				id:searchList[i].id,
 				resocureName:searchList[i].name,
 				serverName:searchList[i].producer!=null?searchList[i].producer.name:"",
 				serverType:searchList[i].businessTypeName,
 				createrData:searchList[i].createTime,
 			})
 		}
 		ev.loading=false;
 	})
};

export const componentSearchName = (ev,param) => {/*获取服务方名称*/
			 apiSearchName(param).then((res)=>{
			 	console.log(res);
			 	if(res.data.code==='S100101'){
					 ev.fuwuName = res.data.data.list;
			 	}
			 })

};


//export const componentGetShareCollectList=(ev,param)=>{/*获取共享或者采集的列表*/
//			apiGetShareCollectList(param).then((res)=>res)
//}

export const componentServerRegisterGetFabuArea=(ev,param)=>{/*获取资源网段的发布区域*/
	apiServerRegisterGetFabuArea({"segment":param}).then((res)=>{
		console.log(res);
		if(res.data.code==="S100101"){
			ev.fabuAreaRadio = res.data.data;
			// console.log(res.data.data);
		}
		
	})
}

export const componentServerRegisterGetFabuAreaCollect=(ev,param)=>{/*获取资源网段的采集发布区域*/
	apiServerRegisterGetFabuAreaCollect({"segment":param}).then((res)=>{
		console.log(res);
		if(res.data.code==="S100101"){
			ev.fabuAreaRadio = res.data.data;
		}
		
	})
}

export const componentServerRegister = (ev,param) => {/*注册提交*/
			console.log(param);
			if(Array.isArray(param.businessType)){
				param.businessType = param.businessType.join();
			}
			if(Array.isArray(param.infoType)){
				param.infoType = param.infoType.join();
			}
			if(Array.isArray(param.nodeIds)){
				param.nodeIds = param.nodeIds.join();
			}
			
			apiServerRegister(param).then((res)=>{
			 	console.log(res);
			 	if(res.data.code==="S100101"){
			 		ev.loading=false;
			 		ev.$message({
				            type: 'success',
				            message: res.data.msg
				     });
				     ev.goBack();
			 	}else{
			 		ev.loading=false;
				 	ev.$message({
				            type: 'info',
				            message: res.data.msg
				     });
				     
			 	}
			})
};


export const componentGetYuanData2Type = (ev,param,typdId) => {/*获取元数据，共享返回类的*/
			apiGetYuanData2Type(param).then((res)=>{
			 	console.log(res);
			 	if(res.data.code==="S100101"){
			 		let yuanDataList = res.data.data.list
			 		ev.wenjianFormYuanDataOptions = [];
			 		for(let i in yuanDataList){
			 			if(yuanDataList[i].type === typdId){
			 				ev.wenjianFormYuanDataOptions.push(yuanDataList[i]);
			 			}
			 		}
			 	}
			})
			
};

export const componentGetYuanData2Type3 = (ev,param,typdId) => {/*获取元数据，共享请求类的*/
			apiGetYuanData2Type(param).then((res)=>{
			 	console.log(res);
			 	if(res.data.code==="S100101"){
			 		let yuanDataList = res.data.data.list
			 		ev.wenjianFormYuanDataOptions3=[];
			 		for(let i in yuanDataList){
			 			if(yuanDataList[i].type === typdId){
			 				ev.wenjianFormYuanDataOptions3.push(yuanDataList[i]);
			 			}
			 		}
			 	}
			})
			
};

export const computedAddYuanData = (ev, param) => {/*插入元数据*/
	apiAddYuanData({
		"name": param.zdName,
		"key": param.zdval,
		"dataType": param.type,
		"type": param.shiyongType,
		"minLen": param.minWidth,
		"maxLen": param.maxWidth,
		"ruleIds": param.resource,
		"otherRule": param.desc,
	}).then((res) => {
		if (res.data.code === 'S100101') {
			ev.$message({
				type: 'success',
				message: '新增成功!'
			});
			ev.resetYuanData();
			ev.closeForm();
		} else {
			ev.$message({
				type: 'info',
				message: res.data.msg
			});
		}
	})
}


export const computedConnDataAdd = (ev, param) => {/*增加数据源*/
	apiConnDataAdd(param).then((res) => {
		if (res.data.code === 'S100101') {
			ev.$message({
				type: 'success',
				message: '添加成功!'
			})
			//刷新数据
			if(ev.currentPage=='yuanData'){
				componentGetFTPData(ev,2,ev.resourceWeb);/*ftp数据源,FTP类型*/
			}else if(ev.currentPage=='dataOrigin'){
				componentGetFTPData(ev,3,ev.resourceWeb);/*ftp数据源，数据库类型*/
			}
			
			ev.dialogVisible2 = false;
		} else {
			ev.$message({
				type: 'info',
				message: '添加失败'
			});
		}

	})
}

export const componentGetFTPData = (ev,typdId,resourceWeb) => {/*ftp数据源*/
			apiGetFTPData({typeId:typdId,"segmentId":resourceWeb}).then((res)=>{
			 	console.log(res);
			 	if(res.data.code==="S100101"){
			 		ev.FTPData = res.data.data.list;
			 	}
			})
};

export const componentGetFTPDataMudi = (ev,typdId,resourceWeb) => {/*ftp数据源目的地*/
			apiGetFTPData({typeId:typdId,"segmentId":resourceWeb}).then((res)=>{
			 	console.log(res);
			 	if(res.data.code==="S100101"){
			 		ev.FTPDataMudi = res.data.data.list;
			 	}
			})
};

export const componentPushDetail = (ev,param) => {/*选择该服务，获取详情，用在发布服务的时候*/
			apiPushDetail(param).then((res)=>{
			 	console.log(res);
			 	let arr = ["","接口","文件","数据库"];
			 	if(res.data.code==="S100101"){
			 		ev.searchResult[0].value=res.data.data.id;
			 		ev.searchResult[1].value=res.data.data.producer.name;
			 		ev.searchResult[2].value=res.data.data.producer.contacts.split(';')[0].split(',')[0];
			 		ev.searchResult[3].value=res.data.data.producer.contacts.split(';')[0].split(',')[1];
			 		ev.searchResult[4].value=arr[res.data.data.inServiceDataSource.type];
			 		ev.searchResult[5].value=arr[res.data.data.describe];
			 		/*************************文件表单还是接口表单*******/ 
			 		ev.outputData=res.data.data.inServiceDataSource.outputDataFormList
			 		console.log(ev.outputData);
			 		for (let i in res.data.data.outServiceDataSourceList){
			 			if(res.data.data.outServiceDataSourceList[i].type===1){/*返回接口*/
			 				ev.showForm.shishiJiekou.show=true;
//			 				ev.serverPushform.backType = 1
			 				ev.showForm.shishiJiekou.id=res.data.data.outServiceDataSourceList[i].id;
			 			}
			 			if(res.data.data.outServiceDataSourceList[i].type===2){/*返回文件*/
			 				ev.showForm.wenjian.show=true;
//			 				ev.serverPushform.backType = 2
			 				ev.showForm.wenjian.id =res.data.data.outServiceDataSourceList[i].id;
			 				ev.filePath = res.data.data.outServiceDataSourceList[i].filePath;
			 			}
			 		}
			 		if(res.data.data.accessTactics){
			 			ev.generalAccessPolicy[0].value = res.data.data.accessTactics.frequency+ev.frequencyArray[ res.data.data.accessTactics.frequencyUnit-1]||""
			 			ev.generalAccessPolicy[1].value = res.data.data.accessTactics.flow+ev.flowArray[res.data.data.accessTactics.flowUnit-1]||""
			 			ev.generalAccessPolicy[2].value = res.data.data.accessTactics.timeValue===null?'不限':ev.timeTpyeArray[res.data.data.accessTactics.timeTpye-1]+':'+res.data.data.accessTactics.timeValue;
			 		}
			 		
			 		/*****************************************/
			 		ev.areaPush = res.data.data.areaList;
			 	}
			})
};

export const componentSearchServer = (ev,businessTypeIds,infoTypeIds) => {/*获取选择的资源*/
			console.log(businessTypeIds);
			apiSearchServer({
				"businessTypeIds":[businessTypeIds],
				"serviceType":1,
				"infoTypeIds":[infoTypeIds]
			}).then((res)=>{
			 	console.log(res);
			 	if(res.data.code==="S100101"){
			 		ev.searchType=res.data.data.list;
			 	}
			})
};


export const componentDealForm = (ev) => {/*计算即将发布的数据*/
		ev.form.nodeIds = ev.serverPushform.areaPush;

		console.log(ev.form);
		ev.tongyongTimeSubmit=!ev.tongyongTimeSubmit;
//		ev.wenjianTimeSubmit =!ev.wenjianTimeSubmit;	
//		ev.shishiTimeSubmit =!ev.shishiTimeSubmit;
		
		console.log(ev.form);
		console.log(ev.serverPushform);
};

export const componentServerPublic =(ev)=>{/*提交发布的数据*/
		ev.loading = true;
		apiDealForm(ev.form).then((res)=>{
				if(res.data.code==="S100101"){
			 		ev.$message({
				            type: 'success',
				            message: res.data.msg
				     });
				     ev.closeForm();
			 	}else{
				 	ev.$message({
				            type: 'info',
				            message: res.data.msg+'且请你重新填写服务返回方式'
				     });  
				    ev.loading = false;
				   	ev.reset();
			 	}
		})
}

export const componentServerUpdata =(ev)=>{/*提交发布更新的数据*/
		ev.loading = true;
		apiDealFormUpdata(ev.form).then((res)=>{
				if(res.data.code==="S100101"){
			 		ev.$message({
				            type: 'success',
				            message: res.data.msg
				     });
				     ev.closeForm();
			 	}else{
				 	ev.$message({
				            type: 'info',
				            message: res.data.msg
				     });
				     ev.loading = false;
			 	}
		})
}

export const componentGetServerList = (ev,aearId) => {/*获取请求方*/
			apiGetServerList({
				"name":"",
				"type":0,
				"nodeIds":aearId,
				"isPageAble": "false"
			}).then((res)=>{
			 	console.log(res);
			 	if(res.data.code==="S100101"){
			 		ev.everyAreaCheckBox=res.data.data.list;
			 	}
			})
};


export const componentCollectFormPush =(ev)=>{/*提交采集服务的数据*/
		apiCollectFormPush(ev.form).then((res)=>{
				if(res.data.code==="S100101"){
			 		ev.$message({
				            type: 'success',
				            message: res.data.msg
				    });
				    ev.goBack();
			 	}else{
				 	ev.$message({
				            type: 'info',
				            message: res.data.msg+'并请你重新填写，以免数据错误'
				    });
				    ev.reset();
			 	}
		})
}






/******************************详情和修改********************************/

export const componentGetDetail = (ev,param) => {/*获取资源注册的详情*/
			apiPushDetail(param).then((res)=>{
			 
				ev.detailData=JSON.parse(JSON.stringify(ev.detailDataBackUp));
				let arr = ["","接口","文件","数据库"];
				let segmentIdName; 
			 	
			 	if(res.data.code==="S100101"){
					 /*基本信息*/
						console.log(ev.treeSeach.segment);
						ev.treeSeach.segment.map(req=>{
							if(req.id === res.data.data.segmentId){
								segmentIdName = req.name
							}
						});
						ev.detailData[0].elForm[0].value=res.data.data.name
						ev.detailData[0].elForm[1].value=res.data.data.id
						ev.detailData[0].elForm[2].value=segmentIdName
						ev.detailData[0].elForm[3].value=res.data.data.producer.name
						ev.detailData[0].elForm[4].value=res.data.data.type===1?'标准服务':'业务类型'
						let businessType = res.data.data.businessType.split(',');
						let infoType = res.data.data.infoType.split(',');
						for(let i in businessType){
							apiDictionarySearchById({"type":'business_type',"id":businessType[i]}).then((res)=>{
								ev.detailData[0].elForm[5].value.push(res.data.data.list[0].name)
							})
						}
						for(let i in infoType){
							apiDictionarySearchById({"type":'info_type',"id":infoType[i]}).then((res)=>{
								ev.detailData[0].elForm[6].value.push(res.data.data.list[0].name)
							})
						}
						ev.detailData[0].elForm[7].value=res.data.data.describe
						/************************************************************/
						/*资源信息*/
						switch (res.data.data.inServiceDataSource.type){
							case 1:
							ev.jiekouDetailData[0].value='实时接口'
							ev.jiekouDetailData[1].value =res.data.data.inServiceDataSource.url;
							ev.jiekouDetailData[2].value = res.data.data.inServiceDataSource.protocalType;
							ev.jiekouDetailData[3].value = res.data.data.inServiceDataSource.requestMethod;
							ev.jiekouDetailData[4].value = res.data.data.inServiceDataSource.requestDataType;
							let inputDataFormList = res.data.data.outServiceDataSourceList[0].inputDataFormList;
							ev.jiekouDetailData[5].value=[];
							for(let i in  inputDataFormList){
								ev.jiekouDetailData[5].value.push(
									[
          								{
          									name:'中文名',
          									value:inputDataFormList[i].name
          								},
          								{
          									name:'参数名',
          									value:inputDataFormList[i].key
          								},
          								{
          									name:'对应的元数据',
          									value:inputDataFormList[i].metaDataId	
          								},
          								{
          									name:'是否必需',
          									value:inputDataFormList[i].isNecessary===1?'必需':'不必需'	
          								},
          								{
          									name:'是否校验',
          									value:inputDataFormList[i].isValid===1?'校验':'不校验'	
          								},
          							],
								)
							}
							let outputDataFormList = res.data.data.inServiceDataSource.outputDataFormList;
							ev.jiekouDetailData[6].value=[];
							for(let i in outputDataFormList){
								ev.jiekouDetailData[6].value.push(
									[
										{
          									name:'参数名',
          									value:outputDataFormList[i].key	
          								},
          								{
          									name:'中文名',
          									value:outputDataFormList[i].name	
          								},
          								{
          									name:'对应的元数据',
          									value:outputDataFormList[i].metaDataId	
          								},
									]
								)
							}
							ev.detailData[1].elForm = ev.jiekouDetailData;
								break;
							case 2:
							ev.wenjianDetailData[0].value = "文件";
							ev.wenjianDetailData[1].value=res.data.data.inServiceDataSource.connDatasourceId;
							ev.wenjianDetailData[2].value = res.data.data.inServiceDataSource.filePath;
							ev.wenjianDetailData[3].value = res.data.data.inServiceDataSource.fileName;
							let outputDataFormList2 = res.data.data.inServiceDataSource.outputDataFormList
							ev.wenjianDetailData[4].value=[];
							for (let i in outputDataFormList2){
								ev.wenjianDetailData[4].value.push(
									[
	          								{
	          									name:'中文名',
	          									value:outputDataFormList2[i].name	
	          								},
	          								{
	          									name:'对应的元数据',
	          									value:outputDataFormList2[i].metaDataId	
	          								},
									]
								)
							}
							for(let i in res.data.data.outServiceDataSourceList){
								if(res.data.data.outServiceDataSourceList[i].type===1){
									let inputDataFormList2 = res.data.data.outServiceDataSourceList[i].inputDataFormList
									ev.wenjianDetailData[5].value=[];
									for (let k in inputDataFormList2){
										ev.wenjianDetailData[5].value.push(
											[
												{
	          										name:'参数名',
	          										value:inputDataFormList2[k].key	
	          									},
	          									{
	          										name:'对应的元数据',
	          										value:inputDataFormList2[k].metaDataId	
	          									},
	          									{
	          										name:'校验规则',
	          										value:inputDataFormList2[k].opRule	
	          									},
	          									{
	          										name:'是否必须',
	          										value:inputDataFormList2[k].isNecessary===1?'必须':'不必须'	
	          									},
	          									{
	          										name:'是否校验',
	          										value:inputDataFormList2[k].isNecessary===1?'校验':'不校验'
	          									},
											]
										)
									}
								}else if(res.data.data.outServiceDataSourceList[i].type===2){
									let inputDataFormList3 = res.data.data.outServiceDataSourceList[i].inputDataFormList
									ev.wenjianDetailData[6].value=[];
									for (let k in inputDataFormList3){
										ev.wenjianDetailData[6].value.push(
											[
												{
	          										name:'参数名',
	          										value:inputDataFormList3[k].key	
	          									},
	          									{
	          										name:'对应的元数据',
	          										value:inputDataFormList3[k].metaDataId	
	          									},
	          									{
	          										name:'校验规则',
	          										value:inputDataFormList3[k].opRule	
	          									},
	          									{
	          										name:'是否必须',
	          										value:inputDataFormList3[k].isNecessary===1?'必须':'不必须'	
	          									},
	          									{
	          										name:'是否校验',
	          										value:inputDataFormList3[k].isNecessary===1?'校验':'不校验'
	          									},
											]
										)
									}
									ev.wenjianDetailData[7].value =res.data.data.outServiceDataSourceList[i].filePath;
								}
							}
							ev.detailData[1].elForm = ev.wenjianDetailData;
							
							break;
							case 3:
							ev.dbdataDetailData[0].value="数据库"
							ev.dbdataDetailData[1].value = res.data.data.inServiceDataSource.connDatasourceId
							ev.dbdataDetailData[2].value = res.data.data.inServiceDataSource.sql
							let  outputDataFormList3 = res.data.data.inServiceDataSource.outputDataFormList
							ev.dbdataDetailData[3].value=[]
							for (let i in outputDataFormList3){
								ev.dbdataDetailData[3].value.push(
									[
											{
	          									name:'字段名',
	          									value:outputDataFormList3[i].key	
	          								},
	          								{
	          									name:'中文名',
	          									value:outputDataFormList3[i].name	
	          								},
	          								{
	          									name:'对应的元数据',
	          									value:outputDataFormList3[i].metaDataId	
	          								},
									]
								)
							}
							for(let i in res.data.data.outServiceDataSourceList){
								if(res.data.data.outServiceDataSourceList[i].type===1){
									let inputDataFormList3 = res.data.data.outServiceDataSourceList[i].inputDataFormList
									ev.dbdataDetailData[4].value=[]
									for (let k in inputDataFormList3){
										ev.dbdataDetailData[4].value.push(
											[
												{
	          										name:'参数名',
	          										value:inputDataFormList3[k].key	
	          									},
	          									{
	          										name:'对应的元数据',
	          										value:inputDataFormList3[k].metaDataId	
	          									},
	          									{
	          										name:'校验规则',
	          										value:inputDataFormList3[k].opRule	
	          									},
	          									{
	          										name:'是否必须',
	          										value:inputDataFormList3[k].isNecessary===1?'必须':'不必须'	
	          									},
	          									{
	          										name:'是否校验',
	          										value:inputDataFormList3[k].isNecessary===1?'校验':'不校验'
	          									},
											]
										)
									}
								}else if(res.data.data.outServiceDataSourceList[i].type===2){
									let inputDataFormList4 = res.data.data.outServiceDataSourceList[i].inputDataFormList
									ev.dbdataDetailData[5].value=[]
									for (let k in inputDataFormList4){
										ev.dbdataDetailData[5].value.push(
											[
												{
	          										name:'参数名',
	          										value:inputDataFormList4[k].key	
	          									},
	          									{
	          										name:'对应的元数据',
	          										value:inputDataFormList4[k].metaDataId	
	          									},
	          									{
	          										name:'校验规则',
	          										value:inputDataFormList4[k].opRule	
	          									},
	          									{
	          										name:'是否必须',
	          										value:inputDataFormList4[k].isNecessary===1?'必须':'不必须'	
	          									},
	          									{
	          										name:'是否校验',
	          										value:inputDataFormList4[k].isNecessary===1?'校验':'不校验'
	          									},
											]
										)
									}
									ev.dbdataDetailData[6].value =res.data.data.outServiceDataSourceList[i].filePath;
								}
							}
							ev.detailData[1].elForm = ev.dbdataDetailData;
								break;
							default:
								break;
						}
						/************************************************************/
						/*通用策略*/
						let flowArray = ["","M/小时","M/天","M/月"];
						let frequencyArray = ["","次/小时","次/天","次/月"];
						let timeTpyeArray = ["不限","每天","每周","每月"];
						if(res.data.data.accessTactics!=null){
							ev.detailData[2].elForm[0].value=res.data.data.accessTactics.frequency+''+frequencyArray[res.data.data.accessTactics.frequencyUnit];
							ev.detailData[2].elForm[1].value=res.data.data.accessTactics.flow+''+frequencyArray[res.data.data.accessTactics.flowUnit];
							ev.detailData[2].elForm[2].value = res.data.data.accessTactics.timeValue+'  '+timeTpyeArray[res.data.data.accessTactics.timeTpye];
						}
						/****************************************************************/
						/*发布信息*/
						for ( let i in res.data.data.areaList){
							ev.detailData[3].elForm[0].value.push(res.data.data.areaList[i].name);
						}
			 	}
			})
};

export const computedGroupDetail=(ev,id)=>{/*编排服务的详情*/
	apiGroupDetail(id).then((res)=>{
//		ev.detailData = ev.detailDataReset;
		ev.detailData=JSON.parse(JSON.stringify(ev.detailDataReset));
		if(res.data.code = "S100101"){
				ev.detailData[0].elForm[0].value = res.data.data.name;
				ev.detailData[0].elForm[1].value = res.data.data.areaName;
				if(res.data.data.smResourceServiceVo.accessTactics!=null){
					let  frequencyUnitArray = ["","次/小时","次/天","次/月"];
					let  flowUnitArray = ['','M/小时',"M/天","M/月"];
					let  timeArray = ['不限','每天','每周','每月'];
					ev.detailData[0].elForm[2].value.push(
						[	
								{
									name:'按频率控制',
									value:res.data.data.smAccessTactics.frequency+''+frequencyUnitArray[res.data.data.smAccessTactics.frequencyUnit]
								},
								{
									name:'按流量控制',
									value:res.data.data.smAccessTactics.flow+''+flowUnitArray[res.data.data.smAccessTactics.flowUnit]
								},
								{
									name:'访问时间段',
									value:res.data.data.smAccessTactics.timeValue+''+timeArray[res.data.data.smAccessTactics.timeTpye]
								}
						]
					)
				}
				ev.detailData[0].elForm[3].value = res.data.data.nodeSn;
				ev.detailData[0].elForm[4].value = res.data.data.smResourceServiceVo.businessType.split(',');
				ev.detailData[0].elForm[5].value = res.data.data.smResourceServiceVo.infoType.split(',');
				ev.detailData[0].elForm[6].value = res.data.data.smResourceServiceVo.describe;
				/*****************************baseInfo**********************************/
				
				
				/********************************请求方名称*******************************/
				if(res.data.data.smAuthResourceServiceVos.length!=0){
					for(let i in res.data.data.smAuthResourceServiceVos){
						if(res.data.data.smAuthResourceServiceVos[i].smOrganization!=null){
							ev.detailData[2].elForm[0].value.push(
								[
									{
										name:'请求方名称',
										value:res.data.data.smAuthResourceServiceVos[i].smOrganization.name
									},
									{
										name:'联系方式',
										value:res.data.data.smAuthResourceServiceVos[i].smOrganization.contacts
									}	
								]
							)
						}
					}
				}
				/********************************请求方名称*******************************/
				
				/*过敏或者输出*/
					if(res.data.data.smGroupOutputFieldViewVos.length!=0){
						for(let i in res.data.data.smGroupOutputFieldViewVos){
							if(res.data.data.smGroupOutputFieldViewVos[i].position!=null){
								for(let k in res.data.data.smGroupOutputFieldViewVos[i].smOutputDataForm){
									ev.detailData[3].elForm[0].value.push(
										[
											{
												name:'敏感词脱敏位置',
												value:res.data.data.smGroupOutputFieldViewVos[i].position
											},
											{
												name:'长度',
												value:res.data.data.smGroupOutputFieldViewVos[i].length
											},
											{
												name:'脱敏规则',
												value:res.data.data.smGroupOutputFieldViewVos[i].replaceStr
											},
											{
												name:'脱敏词名称',
												value:res.data.data.smGroupOutputFieldViewVos[i].smOutputDataForm[k].name
											},
										]
									)
								}
							}else{
								for(let k in res.data.data.smGroupOutputFieldViewVos[i].smOutputDataForm){
									ev.detailData[3].elForm[1].value.push(
										[
											{
												name:'中文名',
												value:res.data.data.smGroupOutputFieldViewVos[i].smOutputDataForm[k].name
											},
											{
												name:'字段名',
												value:res.data.data.smGroupOutputFieldViewVos[i].smOutputDataForm[k].key
											},
										]
									)
								}
							}
						}
						
					}
				ev.detailLoading.close();
				ev.currentPage="2";	
		}
	})
}


export const  computedShareDetail=(ev,param)=>{/*获取发布的详情*/
	apiShareDetail({"id":param}).then((res)=>{
//		ev.detailData = ev.detailDataReset/*重置数据,这样只是浅拷贝，不行*/
		ev.detailData=JSON.parse(JSON.stringify(ev.detailDataReset));/*这样写才行*/
		if(res.data.code = "S100101"){
			ev.detailData[0].elForm[0].value = res.data.data.name;
			ev.detailData[0].elForm[1].value = res.data.data.areaName;
//			ev.detailData[0].elForm[2].value = res.data.data.smResourceServiceVo.accessTactics;
			if(res.data.data.smResourceServiceVo.accessTactics!=null){
				let  frequencyUnitArray = ["","次/小时","次/天","次/月"];
				let  flowUnitArray = ['','M/小时',"M/天","M/月"];
				let  timeArray = ['不限','每天','每周','每月'];
				ev.detailData[0].elForm[2].value.push(
					[	
							{
								name:'按频率控制',
								value:res.data.data.smAccessTactics.frequency+''+frequencyUnitArray[res.data.data.smAccessTactics.frequencyUnit]
							},
							{
								name:'按流量控制',
								value:res.data.data.smAccessTactics.flow+''+flowUnitArray[res.data.data.smAccessTactics.flowUnit]
							},
							{
								name:'访问时间段',
								value:res.data.data.smAccessTactics.timeValue+''+timeArray[res.data.data.smAccessTactics.timeTpye]
							}
					]
				)
			}
			ev.detailData[0].elForm[3].value = res.data.data.smResourceServiceVo.id;
			ev.detailData[0].elForm[4].value = res.data.data.smResourceServiceVo.businessType.split(',');
			ev.detailData[0].elForm[5].value = res.data.data.smResourceServiceVo.infoType.split(',');
			ev.detailData[0].elForm[6].value = res.data.data.smResourceServiceVo.describe;
			if(res.data.data.smResourceServiceVo.outServiceDataSourceList.length!=0&&res.data.data.smResourceServiceVo.outServiceDataSourceList!=null){
							ev.detailData[0].elForm[7].value = res.data.data.smResourceServiceVo.outServiceDataSourceList[0].type;
							let inputDataFormList = res.data.data.smResourceServiceVo.outServiceDataSourceList[0].inputDataFormList;
							for(let i in inputDataFormList){
								ev.detailData[0].elForm[8].value.push(
									[
											{
					          					name:'参数名称',
					          					value:inputDataFormList[i].name
					          				},
					          				{
					          					name:'是否必填',
					          					value:inputDataFormList[i].isNecessary===1?'必填':'不必填'
					          				},
					          				{
					          					name:'是否校验',
					          					value:inputDataFormList[i].isValid===1?'校验':'不校验'
					          				},
					          				{
					          					name:'校验规则',
					          					value:inputDataFormList[i].opRule===null?'无':inputDataFormList[i].opRule
					          				},
									]
								)
							}
			}
			if(res.data.data.smAccessTactics!=null){
				let  frequencyUnitArray = ["","次/小时","次/天","次/月"];
				let  flowUnitArray = ['','M/小时',"M/天","M/月"];
				let  timeArray = ['不限','每天','每周','每月'];
				ev.detailData[0].elForm[9].value.push(
					[	
							{
								name:'按频率控制',
								value:res.data.data.smAccessTactics.frequency+''+frequencyUnitArray[res.data.data.smAccessTactics.frequencyUnit]
							},
							{
								name:'按流量控制',
								value:res.data.data.smAccessTactics.flow+''+flowUnitArray[res.data.data.smAccessTactics.flowUnit]
							},
							{
								name:'访问时间段',
								value:res.data.data.smAccessTactics.timeValue+''+timeArray[res.data.data.smAccessTactics.timeTpye]
							}
					]
				)
			}
			if(res.data.data.smResourceServiceVo.producer!=null){
				ev.detailData[1].elForm[0].value = res.data.data.smResourceServiceVo.producer.name
				ev.detailData[1].elForm[1].value = res.data.data.smResourceServiceVo.producer.contacts
			}
			if(res.data.data.smAuthResourceServiceVos.length!=0){
				for(let i in res.data.data.smAuthResourceServiceVos){
					if(res.data.data.smAuthResourceServiceVos[i].smOrganization!=null){
						ev.detailData[2].elForm[0].value.push(
							[
								{
									name:'请求方名称',
									value:res.data.data.smAuthResourceServiceVos[i].smOrganization.name
								},
								{
									name:'联系方式',
									value:res.data.data.smAuthResourceServiceVos[i].smOrganization.contacts
								}	
							]
						)
					}
				}
			}
			if(res.data.data.outputFieldViewVos.length!=0){
				for(let i in res.data.data.outputFieldViewVos){
					if(res.data.data.outputFieldViewVos[i].position!=null){
						ev.detailData[3].elForm[0].value.push(
							[
								{
									name:'敏感词脱敏位置',
									value:res.data.data.outputFieldViewVos[i].position
								},
								{
									name:'长度',
									value:res.data.data.outputFieldViewVos[i].length
								},
								{
									name:'脱敏规则',
									value:res.data.data.outputFieldViewVos[i].replaceStr
								},
								{
									name:'脱敏词名称',
									value:res.data.data.outputFieldViewVos[i].glOutPutDataForm.name
								},
							]
						)
					}else{
						ev.detailData[3].elForm[1].value.push(
							[
								{
									name:'中文名',
									value:res.data.data.outputFieldViewVos[i].selectOutputDataForm.name
								},
								{
									name:'字段名',
									value:res.data.data.outputFieldViewVos[i].selectOutputDataForm.key
								},
							]
						)
					}
				}
				
			}
			ev.detailLoading.close();
			ev.currentPage="2";
		}
	})
}



export const  computedShareServerDetailUpdata=(ev,param)=>{/*计算发布服务的更新*/
	apiShareDetail({"id":param}).then((res)=>{
		console.log(res);
		ev.form.nopublicId = res.data.data.id;
		ev.form.id = res.data.data.smResourceServiceVo.id;
		ev.form.name = res.data.data.name;
		ev.changeSearchType(res.data.data.smResourceServiceVo.id);
		ev.form.nodeIds = res.data.data.areaId;
		ev.form.outFileType =res.data.data.outFileType
		ev.serverPushform.areaPush[0] = res.data.data.areaId
		
		ev.form.outServiceDataSource.id = res.data.data.smResourceServiceVo.outServiceDataSourceList[0].id;
		ev.form.outServiceDataSource.type=res.data.data.smResourceServiceVo.outServiceDataSourceList[0].type;
		ev.upDataForm = res.data.data.outputFieldViewVos;
		ev.serverPushform.yewuType = res.data.data.smResourceServiceVo.businessType.split(',')[0];
		ev.serverPushform.resultType =res.data.data.smResourceServiceVo.infoType.split(',')[0];
		
		/*文件返回方式*/
		ev.showBackType = res.data.data.smResourceServiceVo.outServiceDataSourceList[0].type;
		ev.serverPushform.backType = String(res.data.data.smResourceServiceVo.outServiceDataSourceList[0].type);
		
		
		/**特殊策略***/
		ev.cenueHasData = res.data.data.smAccessTactics
	
//		for (let i = 0; i < res.data.data.smAuthResourceServiceVos.length; i++) {
//			ev.everyAreaCheckBox.push(res.data.data.smAuthResourceServiceVos[i].smOrganization);
//		}
		for (let i = 0; i <  res.data.data.smAuthResourceServiceVos.length; i++) {
				for (let k = 0; k < ev.everyAreaCheckBox.length; k++) {
					if(res.data.data.smAuthResourceServiceVos[i].smOrganization.id===ev.everyAreaCheckBox[k].id){
							ev.everyArea.push(
									k
							)
							ev.serverPushform.requesterIdList.push(
								k
							)
					}
				}
		}
	
		/*特殊策略*/
	})

}

export const  computedGetCollectDetail=(ev,param)=>{/*获取采集资源的详情*/
	apiGetCollectDetail({id:param}).then((res)=>{
		ev.detailData = JSON.parse(JSON.stringify(ev.detailDataBackUp))  
			if(res.data.code="S100101"){
				ev.detailData[0].elForm[0].value=res.data.data.smResourceServiceVo.name;
				ev.detailData[0].elForm[1].value=res.data.data.smResourceServiceVo.id;
				ev.detailData[0].elForm[2].value=res.data.data.smResourceServiceVo.segmentId
				ev.detailData[0].elForm[3].value=res.data.data.smResourceServiceVo.serviceType===1?'标准服务':'个性化服务'
				let businessType = res.data.data.smResourceServiceVo.businessType.split(',');
				let infoType = res.data.data.smResourceServiceVo.infoType.split(',');
				for(let i in businessType){
							apiDictionarySearchById({"type":'business_type',"id":businessType[i]}).then((res)=>{
								ev.detailData[0].elForm[4].value.push(res.data.data.list[0].name)
							})
				}
				for(let i in infoType){
							apiDictionarySearchById({"type":'info_type',"id":infoType[i]}).then((res)=>{
								ev.detailData[0].elForm[5].value.push(res.data.data.list[0].name)
							})
				}
				ev.detailData[0].elForm[6].value = res.data.data.smResourceServiceVo.describe
				/**********************************/
				/*运行计划*/
				let runMethodArray = ["",'每分钟','每小时','每日','每周','每月'];
				ev.detailData[1].elForm[0].value = runMethodArray[res.data.data.smResourceServiceVo.smRunPlan.runMethod];
				if(res.data.data.smResourceServiceVo.smRunPlan.runMethod==1||res.data.data.smResourceServiceVo.smRunPlan.runMethod==2){/*没有具体时间*/
					ev.detailData[1].elForm[1].value=res.data.data.smResourceServiceVo.smRunPlan.startTime;
				}else{
					ev.detailData[1].elForm[5].value=res.data.data.smResourceServiceVo.smRunPlan.startTime;
				}
				ev.detailData[1].elForm[2].value=res.data.data.smResourceServiceVo.smRunPlan.intervalTime;
				ev.detailData[1].elForm[3].value=res.data.data.smResourceServiceVo.smRunPlan.endTime;
				ev.detailData[1].elForm[4].value=res.data.data.smResourceServiceVo.smRunPlan.selectTime;
				/*************************************/
				ev.detailData[1].elForm[6].value = res.data.data.isRestart===1?'自动重启':'无'
				for ( let i in res.data.data.smResourceServiceVo.areaList){/*发布区域*/
							ev.detailData[1].elForm[7].value.push(res.data.data.smResourceServiceVo.areaList[i].name);
				}
				ev.detailData[1].elForm[8].value =  res.data.data.cpuNum;
				ev.detailData[1].elForm[9].value =  res.data.data.memory;
				/*******************************************************/
				/*数据来源*/
				ev.detailData[2].elForm[0].value = res.data.data.smResourceServiceVo.inServiceDataSource.type===2?'文件':"数据库";
				ev.detailData[2].elForm[1].value = res.data.data.smResourceServiceVo.inServiceDataSource.connDatasourceId;
				ev.detailData[2].elForm[2].value = res.data.data.smResourceServiceVo.inServiceDataSource.filePath;
				ev.detailData[2].elForm[3].value = res.data.data.specifyFileType===1?'指定文件类别':'指定文件名'
				ev.detailData[2].elForm[4].value = res.data.data.specifyValue
				ev.detailData[2].elForm[5].value = res.data.data.gatherMode===1?'增量采集':'全部采集'
//				ev.detailData[2].elForm[6]
				let outputDataFormList = res.data.data.smResourceServiceVo.inServiceDataSource.outputDataFormList;
				for (let i in outputDataFormList){
					ev.detailData[2].elForm[6].value.push(
						[
									{
	          										name:'中文名',
	          										value:outputDataFormList[i].name	
	          						},
	          						{
	          										name:'对应的元数据',
	          										value:outputDataFormList[i].metaDataId	
	          						},
						]
					)
				}
				/*******************数据目的地*******************/
				ev.detailData[3].elForm[0].value = res.data.data.smResourceServiceVo.outServiceDataSourceList[0].type===2?'文件':'数据库'
				ev.detailData[3].elForm[1].value = res.data.data.smResourceServiceVo.outServiceDataSourceList[0].connDatasourceId
				ev.detailData[3].elForm[2].value = res.data.data.smResourceServiceVo.outServiceDataSourceList[0].filePath
				ev.detailData[3].elForm[3].value = res.data.data.outFileType;
				ev.detailData[3].elForm[4].value = res.data.data.smResourceServiceVo.outServiceDataSourceList[0].fileSaveNameRule;
				ev.detailData[3].elForm[5].value = res.data.data.smResourceServiceVo.outServiceDataSourceList[0].connDatasourceId;
				ev.detailData[3].elForm[6].value = res.data.data.smResourceServiceVo.outServiceDataSourceList[0].sql;
				let inputDataFormList = res.data.data.smResourceServiceVo.outServiceDataSourceList[0].inputDataFormList;
				for (let i in inputDataFormList){
					ev.detailData[3].elForm[7].value.push(
						[
							{
	          										name:'字段名',
	          										value:inputDataFormList[i].key	
	          				},
	          				{
	          										name:'中文名',
	          										value:inputDataFormList[i].name	
	          				},
	          				{
	          										name:'元数据',
	          										value:inputDataFormList[i].metaDataId	
	          				},
						]
					)
				}
			}
	})
}


export const  computedDealCollectUpdata = (ev,param)=>{/*采集资源的数据赛回去*/
	apiGetCollectDetail({id:param}).then((res)=>{
		if(res.data.code ==='S100101'){
					ev.form.name = res.data.data.name;
					ev.form.nopublicId = res.data.data.id;
					ev.form.id = res.data.data.resourceServiceId;
					/*资源网段，区域相关*/
					ev.form.segmentId = res.data.data.smResourceServiceVo.segmentId;
					ev.form.resourceWeb = res.data.data.smResourceServiceVo.segmentId;
					ev.chooseResource(res.data.data.smResourceServiceVo.segmentId);
					ev.form.producerId = res.data.data.smResourceServiceVo.producerId;
					ev.form.nodeIds = res.data.data.areaId;
					for (let i = 0; i < ev.fabuAreaRadio.length; i++) {
						if(ev.fabuAreaRadio[i].id==res.data.data.areaId){
							ev.changefbArea(i);
							ev.form.nodeIds
						}
					}
					ev.form.cpuNum =  res.data.data.cpuNum;
					ev.form.memory = res.data.data.memory;
					/**资源网段，区域相关***/
					ev.form.isRestart = res.data.data.isRestart;
					ev.form.type =String(res.data.data.smResourceServiceVo.type)
					ev.hasDataYwInfoDesc.businessType = res.data.data.smResourceServiceVo.businessType.split(',');
					ev.hasDataYwInfoDesc.infoType = res.data.data.smResourceServiceVo.infoType.split(',');
					ev.hasDataYwInfoDesc.describe = res.data.data.smResourceServiceVo.describe;
					/****运行计划***/
					ev.showYunxingPlane = String(res.data.data.smResourceServiceVo.smRunPlan.runMethod);
					ev.collectServerFrom.yunxingPlane = String(res.data.data.smResourceServiceVo.smRunPlan.runMethod);
					ev.hassmRunPlan.endTime = res.data.data.smResourceServiceVo.smRunPlan.endTime;
					ev.hassmRunPlan.stratTime = res.data.data.smResourceServiceVo.smRunPlan.startTime;
					ev.hassmRunPlan.endTime = res.data.data.smResourceServiceVo.smRunPlan.endTime;
					ev.hassmRunPlan.jiangeHours=res.data.data.smResourceServiceVo.smRunPlan.intervalTime;
					ev.hassmRunPlan.jutiTime=res.data.data.smResourceServiceVo.smRunPlan.startTime;
					ev.hassmRunPlan.chooseWeek=res.data.data.smResourceServiceVo.smRunPlan.selectTime;
					ev.hassmRunPlan.everyMonth=res.data.data.smResourceServiceVo.smRunPlan.selectTime;
					/*****运行计划***/
					
					
					ev.secondForm =String(res.data.data.smResourceServiceVo.inServiceDataSource.type);
					ev.form.inServiceDataSource.type = String(res.data.data.smResourceServiceVo.inServiceDataSource.type);
					ev.thirdForm = String(res.data.data.smResourceServiceVo.outServiceDataSourceList[0].type);
					ev.form.tableNameDb = res.data.data.smResourceServiceVo.inServiceDataSource.sql;
					ev.form.outServiceDataSource.type = ev.thirdForm;
					/*数据来源-文件*/
					ev.secondFormWenjianForm.type =String(res.data.data.smResourceServiceVo.inServiceDataSource.type);
					ev.secondFormWenjianForm.outFileType = res.data.data.outFileType
					ev.secondFormWenjianForm.gatherMode =  res.data.data.gatherMode
					ev.secondFormWenjianForm.specifyFileType =  res.data.data.specifyFileType
					ev.secondFormWenjianForm.specifyValue =  res.data.data.specifyValue
					ev.secondFormWenjianForm.filePath = res.data.data.smResourceServiceVo.inServiceDataSource.filePath
					ev.secondFormWenjianForm.connDatasourceId = res.data.data.smResourceServiceVo.inServiceDataSource.connDatasourceId
					ev.secondFormWenjianForm.outputDataFormList = res.data.data.smResourceServiceVo.inServiceDataSource.outputDataFormList;
					/*数据来源-文件*/
					
					/*数据目的地-文件*/
					ev.thirdFormWenjianForm.type = String(res.data.data.smResourceServiceVo.outServiceDataSourceList[0].type);
					ev.thirdFormWenjianForm.connDatasourceId = res.data.data.smResourceServiceVo.outServiceDataSourceList[0].connDatasourceId;
					ev.thirdFormWenjianForm.filePath = res.data.data.smResourceServiceVo.outServiceDataSourceList[0].filePath;
					ev.thirdFormWenjianForm.fileSaveNameRule = res.data.data.smResourceServiceVo.outServiceDataSourceList[0].fileSaveNameRule;
					ev.thirdFormWenjianForm.outFileType = res.data.data.outFileType
					/*数据目的地-文件*/
					
					
					
					/*数据来源-数据库*/
					ev.secondFormDBdataForm.type = String(res.data.data.smResourceServiceVo.inServiceDataSource.type);
					ev.secondFormDBdataForm.connDatasourceId =res.data.data.smResourceServiceVo.inServiceDataSource.connDatasourceId;
					ev.secondFormDBdataForm.sql = res.data.data.smResourceServiceVo.inServiceDataSource.sql;
					ev.secondFormDBdataForm.outputDataFormList = res.data.data.smResourceServiceVo.inServiceDataSource.outputDataFormList;
					
					/*数据目的地-数据库*/
					for(let i in ev.secondFormDBdataForm.outputDataFormList){	//对应该的来源字段回显处理
						ev.sourceField.push({id:ev.secondFormDBdataForm.outputDataFormList[i].order,tickName:ev.secondFormDBdataForm.outputDataFormList[i].key});
					}
					// console.log(ev.sourceField);
					ev.thirdFormDBdataForm.type =String(res.data.data.smResourceServiceVo.outServiceDataSourceList[0].type); 
					ev.thirdFormDBdataForm.connDatasourceId =  res.data.data.smResourceServiceVo.outServiceDataSourceList[0].connDatasourceId;
					ev.thirdFormDBdataForm.inputDataFormList = res.data.data.smResourceServiceVo.outServiceDataSourceList[0].inputDataFormList;
					ev.thirdFormDBdataForm.sql =  res.data.data.smResourceServiceVo.outServiceDataSourceList[0].sql;
					console.log(ev.thirdFormDBdataForm);
					/*数据目的地*/
		}else{
					ev.$message({
				            type: 'info',
				            message: res.data.msg
				     }); 
		}
	})
}

export const computedDealRegisterUpdata=(ev,param)=>{/*服务注册资源的数据赛回去*/
	apiPushDetail(param).then((res)=>{
		ev.form.id = param.id;
		ev.form.name = res.data.data.name;
		ev.form.segmentId = res.data.data.segmentId;
		ev.chooseResource(res.data.data.segmentId);
		ev.form.producerId = res.data.data.producer.id;
		ev.form.type = String(res.data.data.type);
		ev.hasDataYwInfoDesc.businessType = res.data.data.businessType.split(',');
		ev.hasDataYwInfoDesc.infoType = res.data.data.infoType.split(',');
		ev.hasDataYwInfoDesc.describe = res.data.data.describe;
		/*通用策略*/
		if(res.data.data.accessTactics!=null){
			ev.cenueHasData = res.data.data.accessTactics
		}
		/*区域*/
		ev.form.nodeIds=res.data.data.nodeIds.split(',')
		console.log(ev.form.nodeIds);
		let secondFormType=["","jiekou","wenjian","datadb"];
		
		ev.secondForm = secondFormType[res.data.data.inServiceDataSource.type];
		ev.form.dataOrigin = ev.secondForm;	//添加回显文件类型
		ev.HasDataForm.inServiceDataSource = res.data.data.inServiceDataSource
		ev.HasDataForm.outServiceDataSourceList = res.data.data.outServiceDataSourceList
		
	})
}


export const componentCollectFormUpdata =(ev)=>{/*提交采集服务修改的数据*/
		apiCollectFormUpdata(ev.form).then((res)=>{
				if(res.data.code==="S100101"){
			 		ev.$message({
				            type: 'success',
				            message: res.data.msg
				     });
				     ev.goBack();
			 	}else{
				 	ev.$message({
				            type: 'info',
				            message: res.data.msg
				     });  
			 	}
		})
}


export const componentServerRegisterFormUpdata=(ev,param)=>{/*提交服务注册修改的数据*/
	
			console.log(param);
			if(Array.isArray(param.businessType)){
				param.businessType = param.businessType.join();
			}
			if(Array.isArray(param.infoType)){
				param.infoType = param.infoType.join();
			}
			if(Array.isArray(param.nodeIds)){
				param.nodeIds = param.nodeIds.join();
			}
	
	apiServerRegisterFormUpdata(param).then((res)=>{
				if(res.data.code==="S100101"){
			 		ev.$message({
				            type: 'success',
				            message: res.data.msg
				     });
				     ev.goBack();
			 	}else{
				 	ev.$message({
				            type: 'info',
				            message: res.data.msg
				     });  
			 	}
	})
}

export const computedCheckName=(ev,value,id='',valiType)=>{/*检测有无重名*/
	apiCheckName(
		{
			valiType:valiType,
			id:id,
			valiName:value,
		}
	).then((res)=>{
		console.log(res);
		ev.has = res.data.data;
	})
}

//数据库查询表操作
export const computedGetTable = (ev,param) => {
	apiGetTable(param).then((res)=>{
		if(res.data.code === 'S100101'){
			ev.DatabaseTableData = res.data.data.list;
		}else{
			console.log('出错了');
		}
		
	})
}

//数据库查询表字段操作
export const computedGetValue = (ev,param) => {
	apiGetValue(param).then((res)=>{
		if(res.data.code === 'S100101'){
			// console.log(res);
			// console.log('数据库查询表字段操作');
			let zhiDuan = res.data.data.list;
			ev.fieldName = res.data.data.list;
			console.log(zhiDuan)
			for(let i =0; i<zhiDuan.length; i++){
				ev.adddataPiPeiTableData(zhiDuan[i].name,i);
			}
		}else{
			console.log('出错了');
		}
	})
}

//数据库查询表字段操作
export const computedGetValueDestination = (ev,param) => {
	apiGetValue(param).then((res)=>{
		if(res.data.code === 'S100101'){
			// console.log(res);
			// console.log('数据库查询表字段操作');
			let zhiDuan = res.data.data.list;
			ev.fieldName = res.data.data.list;
			console.log(zhiDuan)
			for(let i =0; i<zhiDuan.length; i++){
				ev.adddataPiPeiTableData(zhiDuan[i].name);
			}
		}else{
			console.log('出错了');
		}
	})
}

//采集列表运行
export const computedCollectListRun = (vm,id) => {
	apiCollectListRun(id).then((res)=>{
		if(res.data.code === 'S100101'){
			if(res.data.data === true){
				vm.$message("发布成功")
			}else{
				vm.$message("发布失败")
			}
		}else{
			console.log('出错了');
		}
	})
}

//采集列表停止
export const computedCollectListStop = (vm, id) => {
	apiCollectListStop(id).then((res) => {
		if(res.data.code === 'S100101'){
			if(res.data.data === true){
				vm.$message("暂停成功")
			}else{
				vm.$message("暂停失败")
			}
		}else{
			console.log('出错了');
		}
	});
}

//查看建表SQL
export const computedGentableSql = (vm, obj) => {
	apiGentableSql(obj).then((res) => {
		if(res.data.code === 'S100101'){
			console.log(res.data.data);
			alert(res.data.data);
		}else{
			console.log("出错了");
		}
	})
}
